ultrasonic3 2.2.0
Loading...
Searching...
No Matches
app_config.h
Go to the documentation of this file.
1/*
2<!-- BEGIN INVN LICENSE -->
3TDK InvenSense 5 Clause License
4
5Copyright (c) 2025, Invensense, Inc.
6
7All rights reserved.
8
9Redistribution and use in source and binary forms, with or without modification,
10are permitted provided that the following conditions are met:
11
121. Redistributions of source code must retain the above copyright notice, this
13list of conditions and the following disclaimer.
14
152. Redistributions in binary form must reproduce the above copyright notice,
16this list of conditions and the following disclaimer in the documentation and/or
17other materials provided with the distribution.
18
193. Neither the name of the copyright holder nor the names of its contributors
20may be used to endorse or promote products derived from this software without
21specific prior written permission.
22
234. This software, with or without modification, must only be used with a
24TDK InvenSense sensor.
25
265. Any software provided in binary form under this license, whether embedded
27in source code or provided as a compiled library or application, must not
28be reverse engineered, decompiled, modified and/or disassembled.
29
30THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
34ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
37ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40<!-- END INVN LICENSE -->
41*/
42
44#ifndef APP_CONFIG_H
45#define APP_CONFIG_H
46
47/*=========================== Sensor Configuration ===========================*/
48
49/* Operating mode for the sensor(s)
50 * These two values define the mode in which the sensor(s) will operate.
51 *
52 * - CH_MODE_FREERUN - sensor is triggered from internal RTC
53 * - CH_MODE_TRIGGERED_TX_RX - sensor is hardware triggered. Each measurement
54 * does a transmit followed by a receive
55 * - CH_MODE_TRIGGERED_RX_ONLY - sensor is hardware triggered. Each
56 * measurement does a receive only
57 * - CH_MODE_CONTINUOUS_RX - receiver runs continuously (100% duty cycle)
58 *
59 * The CHIRP_FIRST_SENSOR_MODE value specifies the mode for the first sensor
60 * (lowest numbered) that is present. If only one sensor is attached, this
61 * value must be one of CH_MODE_TRIGGERED_TX_RX, CH_MODE_FREERUN,
62 * or CH_MODE_CONTINUOUS_RX.
63 *
64 * The CHIRP_OTHER_SENSOR_MODE value specifies the mode for all other sensors
65 * that are present.
66 *
67 * For typical Pitch-Catch operation using two or more sensors, set
68 * CHIRP_FIRST_SENSOR_MODE to CH_MODE_TRIGGERED_TX_RX and set
69 * CHIRP_OTHER_SENSOR_MODE to CH_MODE_TRIGGERED_RX_ONLY.
70 *
71 * In CONTINUOUS_RX mode, it is suggested to set CHIRP_RINGDOWN_CANCEL_SAMPLES
72 * to 0.
73 *
74 * Do not mix the TRIGGERED modes with the FREERUN or CONTINUOUS modes.
75 */
76#define CHIRP_FIRST_SENSOR_MODE (CH_MODE_TRIGGERED_TX_RX)
77#define CHIRP_OTHER_SENSOR_MODE (CH_MODE_TRIGGERED_RX_ONLY)
78
79/* Trigger type for the sensor(s)
80 *
81 * To trigger a sensor by generating a pulse on the INT line (hardware), set the
82 * sensor trigger type CHIRP_TRIGGER_TYPE to CH_TRIGGER_TYPE_HW.
83 * To trigger a sensor using software (SPI) interface, set CHIRP_TRIGGER_TYPE
84 * to CH_TRIGGER_TYPE_SW.
85 *
86 * Software triggering is not recommended for multi-sensor pitch-catch operation
87 * because there is a time lag between triggering the sensors.
88 */
89#define CHIRP_TRIGGER_TYPE (CH_TRIGGER_TYPE_HW)
90
91/* Maximum detection range for the sensor
92 * This value will determine how long the sensor "listens" for an ultrasound
93 * signal. Note that the maximum possible range will vary depending on sensor
94 * model and sensor firmware type. If the value specified here is greater than
95 * the maximum possible range, the maximum possible range will be used.
96 */
97#define CHIRP_ICU10201_MAX_RANGE_MM (750) /* maximum range, in mm for ICU10201 */
98#define CHIRP_ICU20201_MAX_RANGE_MM (4000) /* maximum range, in mm for ICU20201 */
99#define CHIRP_ICU30201_MAX_RANGE_MM (7000) /* maximum range, in mm for ICU30201 */
100
101// Static target rejection sample range, in samples (0=disabled)
102/*
103 * This value specifies if static target rejection (STR) will be used. If
104 * CHIRP_STATIC_REJECT_SAMPLES is non-zero, STR will be enabled and will apply
105 * to the specified number of samples at the beginning of a measurement.
106 * The sensor will only report targets that are non-stationary.
107 *
108 * To enable STR filtering for the entire measurement, set this value
109 * to ICU_MAX_NUM_SAMPLES.
110 *
111 * This feature is often combined with target interrupt filtering to reduce the
112 * number of data ready interrupts, for power conservation.
113 */
114#define CHIRP_STATIC_REJECT_SAMPLES (0)
115
116/* Target interrupt filter
117 * This setting controls whether the sensor will generate an interrupt after
118 * every measurement, or only if a target is detected. By default, a data
119 * ready interrupt is generated after every measurement.
120 *
121 * Set this value to non-zero to enable target interrupt filtering. The sensor
122 * will only generate a data ready interrupt if a target was detected during
123 * the measurement.
124 *
125 * This feature is often combined with static target rejection to reduce the
126 * number of data ready interrupts, for power conservation.
127 */
128#define CHIRP_TARGET_INT_FILTER (0)
129
130/* Rx holdoff
131 * This value specifies a certain number of samples at the start of each
132 * measurement that will be ignored during target detection. Although data
133 * from these samples will be measured (and reported if amplitude or I/Q
134 * output is enabled), no target will be reported within this range. This
135 * may be useful for ignoring objects close to the sensor.
136 *
137 * For ICU sensors, the Rx Holdoff setting will modify the detection thresholds
138 * for the specified range of samples.
139 *
140 * Set CHIRP_RX_HOLDOFF_SAMPLES to non-zero to specify a number of samples
141 * to ignore, or zero to disable.
142 */
143#define CHIRP_RX_HOLDOFF_SAMPLES (0)
144
145/* Receive sensor pre-triggering
146 * This value specifies if receive (rx) sensor pre-triggering will be used.
147 * This setting only applies if more than one sensor is used, and one or more
148 * sensor is operating in CH_MODE_TRIGGERED_RX_ONLY.
149
150 * Receive pre-triggering improves performance in pitch-catch operation at
151 * short distances, by triggering the receive-only sensor(s) slightly before
152 * the transmitting sensor. However, this setting will reduce maximum range of
153 * rx-only sensors approximately 200mm, relative to the
154 * CHIRP_MAX_RANGE_MM setting, above.
155 *
156 * Set RX_PRETRIGGER_ENABLE to non-zero to enable rx pretriggering, or zero
157 * to disable.
158 */
159#define CHIRP_RX_PRETRIGGER_ENABLE (1)
160
161/* Maximum number of targets
162 * The specifies the maximum number of separate target objects for which the sensor will
163 * report range and amplitude values.
164 */
165#define CHIRP_MAX_TARGETS (3) /* Maximum number of targets to detect */
166
167/* Target detection thresholds
168 * These definitions set the sensor's target detection thresholds. These thresholds specify
169 * how large a signal must be received, and at what point in the measurement, for the sensor
170 * to indicate that a target was detected and calculate range, etc.
171 *
172 * Each threshold consists of a starting sample number within the measurement and the
173 * corresponding amplitude value that must be reached. A threshold extends until the
174 * starting sample number of the next threshold, if any.
175 *
176 * These values are used to initialize the chirp_detect_thresholds structure defined
177 * in main.c, which is passed to the icu_gpt_algo_configure() function.
178 */
179#define CHIRP_THRESH_0_START (0) /* threshold 0 - must start at sample zero */
180#define CHIRP_THRESH_0_LEVEL (2500)
181
182#define CHIRP_THRESH_1_START (40) /* threshold 1 */
183#define CHIRP_THRESH_1_LEVEL (800)
184
185#define CHIRP_THRESH_2_START (70) /* threshold 2 */
186#define CHIRP_THRESH_2_LEVEL (400)
187
188#define CHIRP_THRESH_3_START (100) /* threshold 3 */
189#define CHIRP_THRESH_3_LEVEL (200)
190
191#define CHIRP_THRESH_4_START (160) /* threshold 4 */
192#define CHIRP_THRESH_4_LEVEL (140)
193
194#define CHIRP_THRESH_5_START (200) /* threshold 5 */
195#define CHIRP_THRESH_5_LEVEL (95)
196
197#define CHIRP_THRESH_6_START (240) /* threshold 6 */
198#define CHIRP_THRESH_6_LEVEL (50)
199
200#define CHIRP_THRESH_7_START (0) /* threshold 7 (not used) */
201#define CHIRP_THRESH_7_LEVEL (0)
202
203/*============================ Measurement Settings ============================*/
204
205/* Configuration of measurement segments
206 * The following symbols define the individual transmit and receive segments within
207 * the measurement.
208 */
209#define CHIRP_TX_SEG_CYCLES (640) /* Transmit segment - length (cycles) */
210#define CHIRP_TX_SEG_PULSE_WIDTH (3) /* width of each cycle pulse */
211#define CHIRP_TX_SEG_PHASE (8) /* tx phase */
212#define CHIRP_TX_SEG_INT_EN (0) /* no interrupt when done */
213
214#define CHIRP_RX_SEG_0_SAMPLES (1) /* Receive segment 0 - single sample */
215#define CHIRP_RX_SEG_0_GAIN_REDUCE (24) /* reduce gain */
216#define CHIRP_RX_SEG_0_ATTEN (1) /* use attenuation */
217#define CHIRP_RX_SEG_0_INT_EN (0) /* no interrupt when done */
218
219#define CHIRP_RX_SEG_1_SAMPLES (295) /* Receive segment 1 - remainder of measurement */
220#define CHIRP_RX_SEG_1_GAIN_REDUCE (0) /* no gain reduction */
221#define CHIRP_RX_SEG_1_ATTEN (0) /* no attenuation */
222#define CHIRP_RX_SEG_1_INT_EN (1) /* generate interrupt when done (if eligible) */
223
224/* Output data rate
225 * This symbol specifies the output data rate for the sensor, i.e. how often
226 * a sample is taken within each measurement.
227 */
228#define CHIRP_SENSOR_ODR (CH_ODR_FREQ_DIV_8)
229
230/* The following symbol enables optimization of the measurement segments to
231 * improve performance at close distances. Additional segments will be inserted
232 * into the sequence that was defined above or imported from a file.
233 *
234 * Set to non-zero to enable measurement optimization.
235 */
236#define CHIRP_MEAS_OPTIMIZE (1) /* if non-zero, meas segments will be optimized */
237
238/*============================ Application Timing ============================*/
239
240/* Define how often the application will get a new sample from the sensor(s)
241 * This macro defines the sensor measurement interval, in milliseconds.
242 *
243 * For sensors in triggered mode (CH_MODE_TRIGGERED_TX_RX or
244 * CH_MODE_TRIGGERED_RX_ONLY), the application will use a periodic timer to
245 * trigger a sensor measurement each time this period elapses.
246 *
247 * For sensors in free-running mode (CH_MODE_FREERUN), the application will
248 * set this period as the sensor's internal sample interval. Additionally, in
249 * free-running mode, a sample-to-sample random "time hop" will be added to
250 * the sample period. This one method of coexistence mitigation when combined
251 * with certain sensor firmware. To disable the time hopping behavior, you
252 * should call ch_freerun_time_hop_disable() from your application.
253 *
254 * For sensors in continuous RX mode, this field is ignored.
255 */
256#define MEASUREMENT_INTERVAL_MS (100)
257
258/*======================== Application Display Options ==========================*/
259
260/* These symbols control what values are displayed for each measurement. */
261#define DISPLAY_AMP_VALUE (1) /* if non-zero, show amplitude for detected target(s) */
262#define DISPLAY_SAMPLE_NUM (1) /* if non-zero, show sample number for detected target(s) */
263
264/* if non-zero, multiple detected targets displayed
265 if zero, only closest target is displayed */
266#define DISPLAY_MULTI_TARGET (1)
267
268#endif /* APP_CONFIG_H */